//自适应
$(".gallery_div").css({
    "height": $(".gallery_div").eq(0).width()+"px"
});
window.onresize = function(){
	$(".gallery_div").css({
		"height": $(".gallery_div").width()+"px"
	});
};

//图片hover
$(".gallery_div").mouseenter(function () {
	$(this).find(".gallery_title").css({
        opacity:1,
        bottom:"0"
	});
});
$(".gallery_div").mouseleave(function () {
    $(this).find(".gallery_title").css({
        opacity:0,
        bottom:"-30%"
    });
});
//图片切换
$(".sub_title_code").click(function () {
	if($(this).hasClass("active"))
	{
		return;
	}
	$(".chapter_sub_title li a").removeClass("active");
    $(this).addClass("active");
    $(".gallery_div.drawing").css({
        opacity:0,
        transform:"scale(0.001)"
    });
    $(".gallery_div.cat").css({
        opacity:0,
        transform:"scale(0.001)"
    });
    setTimeout(function () {
        $(".gallery_div.drawing").css({
            display:"none"
        });
        $(".gallery_div.cat").css({
            display:"none"
        });
        $(".gallery_div.code").css({
            display:"inline-block"
        });
    },300);
    setTimeout(function () {
        $(".gallery_div.code").css({
            opacity:1,
            transform:"scale(1)"
        });
    },400);
});
$(".sub_title_drawing").click(function () {
    if($(this).hasClass("active"))
    {
        return;
    }
    $(".chapter_sub_title li a").removeClass("active");
    $(this).addClass("active");
    $(".gallery_div.code").css({
        opacity:0,
        transform:"scale(0.001)"
    });
    $(".gallery_div.cat").css({
        opacity:0,
        transform:"scale(0.001)"
    });
    setTimeout(function () {
        $(".gallery_div.code").css({
            display:"none"
        });
        $(".gallery_div.cat").css({
            display:"none"
        });
        $(".gallery_div.drawing").css({
            display:"inline-block"
        });
    },300);
    setTimeout(function () {
        $(".gallery_div.drawing").css({
            opacity:1,
            transform:"scale(1)"
        });
    },400);
});
$(".sub_title_cat").click(function () {
    if($(this).hasClass("active"))
    {
        return;
    }
    $(".chapter_sub_title li a").removeClass("active");
    $(this).addClass("active");
    $(".gallery_div.code").css({
        opacity:0,
        transform:"scale(0.001)"
    });
    $(".gallery_div.drawing").css({
        opacity:0,
        transform:"scale(0.001)"
    });
    setTimeout(function () {
        $(".gallery_div.code").css({
            display:"none"
        });
        $(".gallery_div.drawing").css({
            display:"none"
        });
        $(".gallery_div.cat").css({
            display:"inline-block"
        });
    },300);
    setTimeout(function () {
        $(".gallery_div.cat").css({
            opacity:1,
            transform:"scale(1)"
        });
    },400);
});

//联系Zack表单提交
function submit_contact() {
    var name = $("#contact_name").val();
    var email = $("#contact_email").val();
    var content = $("#contact_content").val();

    if(name.length==0 || $.trim(name).length==0 || email.length==0 || $.trim(email).length==0 || content.length==0 || $.trim(content).length==0)
    {
        alert("请将信息填写完整");
    }
    else
    {
        alert("已提交成功，请等待回信~");
    }
    return false;
}